package com.itplh.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * @Description:
 * @Author: tanpeng
 * @Date: 2019-07-11 10:43
 * @Version: V1.0
 */
@Configuration
@MapperScan(value = "com.itplh.modules.**.dao*")
public class MybatisPlusConfig {

    /**
     *  分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * mybatis-plus SQL执行效率插件
     * SQL执行性能分析，开发环境使用，线上不推荐
     */
    @Profile(value = {"dev", "test"})
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        // SQL最大执行时长
        performanceInterceptor.setMaxTime(5000L);
        // SQL是否格式化 默认false
        performanceInterceptor.setFormat(true);
        return performanceInterceptor;
    }

}
